const initialState = {
  trainData: [],
};

export default (state = initialState, { type, payload }: any) => {
  const newState = JSON.parse(JSON.stringify(state));
  switch (type) {
    // 获取车次信息数据
    case "GET-LIST":
      newState.trainData = payload;
      return newState;
    // 添加车次信息
    case "ADD-TRAINDATA":
      let newArr = [...newState.trainData];
      newState.trainData.unshift(payload);
      return newState;

    default:
      return newState;
  }
};
